package com.bjpowernode.boss.mvc.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bjpowernode.boss.common.consants.SysConstants;
import com.bjpowernode.boss.convert.PaymentConvert;
import com.bjpowernode.boss.dao.entity.PayWay;
import com.bjpowernode.boss.mvc.models.AjaxResult;
import com.bjpowernode.boss.mvc.models.pages.PageInfo;
import com.bjpowernode.boss.mvc.service.PayWayService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class PayWayController extends BaseController {

    @Resource
    private PayWayService payWayService;

    @Resource
    private PaymentConvert paymentConvert;
    @GetMapping("/payment/way/pageList")
    public AjaxResult pageList(Integer pageNo, String productCode){
        pageNo = defPageNo(pageNo);
        IPage<PayWay> pageResult = payWayService.pageList(pageNo, SysConstants.PAGE_SIZE, productCode);

        PageInfo page = new PageInfo(pageResult.getCurrent(),pageResult.getPages());

        Map<String,Object> data = new HashMap<>();
        data.put("page",page);
        data.put("list", paymentConvert.toListPayWayVo(pageResult.getRecords()));

        return AjaxResult.ok(data);
    }
}
